/**
 * 
 */
package com.buss.core.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.validator.constraints.NotEmpty;

import com.buss.core.dic.PropertyAlign;
import com.buss.core.dic.PropertyType;
import com.buss.core.utils.SimpleEnumSerializer;

/**
 * 功能数据模型
 * @author 高小勇
 * 创建时间:2011-5-19
 * wcms2.0
 */
@Entity
@Table(name="core_datamodel")
@TableGenerator(name="datamodel_pk_sequence",initialValue=1,allocationSize=1,pkColumnName="seq_col",
		pkColumnValue="datamodel_seq",valueColumnName="seq_val",table="core_pk_sequence")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class DataModel implements Serializable{
	
	private static final long serialVersionUID = -7019730574815768974L;

	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator="datamodel_pk_sequence")
	private Long id;
	
	/**功能菜单编码*/
	@JsonDeserialize
	@ManyToOne(cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	@JoinColumn(name="menuId",nullable=false)
	private Sysmenu menu;
	
	/**属性名称*/
	@Column(nullable=false,length=100)
	@NotEmpty(message="")
	private String propertyName;
	
	/**默认标题*/
	@Column(nullable=false,length=100)
	private String defTitle;
	
	/**标题文字*/
	@Column(nullable=false,length=100)
	private String title;
	
	/**属性显示类型*/
	@Enumerated(EnumType.STRING)
	@Column(nullable=false,length=20)
	private PropertyType propertyType;
	
	/**列对齐方式*/
	@Enumerated(EnumType.STRING)
	@Column(length=20)
	private PropertyAlign propertyAlign;
	
	/**是否允许排序*/
	private Boolean isSortable;
	
	/**排序属性*/
	@Column(length=100)
	private String sortProperty;
	
	/**列表显示顺序*/
	private Integer listSortNum;
	
	/**编辑页面属性显示顺序*/
	private Integer editSortNum;
	
	/**列宽*/
	private Integer colWidth;
	
	/**列表是否显示*/
	private Boolean listIsShow;
	
	/**编辑页面是否显示*/
	private Boolean editIsShow;
	
	/**新增页面时是否显示*/
	private Boolean isReadonly;
	
	/**是否用于列表搜索*/
	private Boolean isSearch;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@JsonIgnore
	public Sysmenu getMenu() {
		return menu;
	}

	public void setMenu(Sysmenu menu) {
		this.menu = menu;
	}

	public String getPropertyName() {
		return propertyName;
	}

	public void setPropertyName(String propertyName) {
		this.propertyName = propertyName;
	}

	public String getDefTitle() {
		return defTitle;
	}

	public void setDefTitle(String defTitle) {
		this.defTitle = defTitle;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@JsonSerialize(using=SimpleEnumSerializer.class)
	public PropertyType getPropertyType() {
		return propertyType;
	}

	public void setPropertyType(PropertyType propertyType) {
		this.propertyType = propertyType;
	}

	
	public PropertyAlign getPropertyAlign() {
		return propertyAlign;
	}

	public void setPropertyAlign(PropertyAlign propertyAlign) {
		this.propertyAlign = propertyAlign;
	}

	public Boolean getIsSortable() {
		return isSortable;
	}

	public void setIsSortable(Boolean isSortable) {
		this.isSortable = isSortable;
	}

	public String getSortProperty() {
		return sortProperty;
	}

	public void setSortProperty(String sortProperty) {
		this.sortProperty = sortProperty;
	}

	public Integer getListSortNum() {
		return listSortNum;
	}

	public void setListSortNum(Integer listSortNum) {
		this.listSortNum = listSortNum;
	}

	public Integer getEditSortNum() {
		return editSortNum;
	}

	public void setEditSortNum(Integer editSortNum) {
		this.editSortNum = editSortNum;
	}

	public Integer getColWidth() {
		return colWidth;
	}

	public void setColWidth(Integer colWidth) {
		this.colWidth = colWidth;
	}

	public Boolean getListIsShow() {
		return listIsShow;
	}

	public void setListIsShow(Boolean listIsShow) {
		this.listIsShow = listIsShow;
	}

	public Boolean getEditIsShow() {
		return editIsShow;
	}

	public void setEditIsShow(Boolean editIsShow) {
		this.editIsShow = editIsShow;
	}
	

	public Boolean getIsReadonly() {
		return isReadonly;
	}

	public void setIsReadonly(Boolean isReadonly) {
		this.isReadonly = isReadonly;
	}

	public Boolean getIsSearch() {
		return isSearch;
	}

	public void setIsSearch(Boolean isSearch) {
		this.isSearch = isSearch;
	}
	
	
}
